package com.zsgeek.wisdchain.qutu.view.home;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.zsgeek.wisdchain.qutu.BaseActivity;
import com.zsgeek.wisdchain.qutu.R;
import com.zsgeek.wisdchain.qutu.base.customControl.ClearEditText;
import com.zsgeek.wisdchain.qutu.tools.TextUtils;
import com.zsgeek.wisdchain.qutu.tools.ToastHelper;

import butterknife.BindView;

/**
 * 阅读规则
 */
public class ReadRuleActivity extends BaseActivity {

    @BindView(R.id.ydsc_tv)
    ClearEditText ydscTv;
    @BindView(R.id.ydjl_tv)
    ClearEditText ydjlTv;
    @BindView(R.id.fxazf_tv)
    ClearEditText fxazfTv;
    @BindView(R.id.dzjl_tv)
    ClearEditText dzjlTv;
    @BindView(R.id.pjjl_tv)
    ClearEditText pjjlTv;
    @BindView(R.id.ggzczsl_tv)
    ClearEditText ggzczslTv;
    private String read_time, read_num, share_num, collect_num, comment_num, agree_num, total;

    @Override
    public int getLayoutId() {
        return R.layout.activity_read_rule;
    }

    @Override
    protected void initView() {
        setTitle("阅读规则");
        setToolbarRight(getString(R.string.save), null, 0, 0, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try {
                    read_time = ydscTv.getText().toString().trim();
                    read_num = ydscTv.getText().toString().trim();
                    share_num = fxazfTv.getText().toString().trim();
                    agree_num = dzjlTv.getText().toString().trim();
                    comment_num = pjjlTv.getText().toString().trim();
                    total = ggzczslTv.getText().toString().trim();
                    if (TextUtils.isEmpty(total)) {
                        ToastHelper.showToast("请设置广告支出总数量");
                        return;
                    }
                    double parseDouble = Double.parseDouble(total);
                    if (parseDouble <= 0) {
                        ToastHelper.showToast("请设置广告支出总数量");
                        return;
                    }
                    Intent intent = new Intent();
                    intent.putExtra("read_time", read_time);
                    intent.putExtra("read_num", read_num);
                    intent.putExtra("share_num", share_num);
                    intent.putExtra("agree_num", agree_num);
                    intent.putExtra("comment_num", comment_num);
                    intent.putExtra("total", total);
                    setResult(-1, intent);
                    finish();
                } catch (NumberFormatException e) {
                    e.printStackTrace();
                }
            }
        });
    }

    @Override
    protected void initDate(Bundle savedInstanceState) {

    }

}
